          <?php $errorTopic = Yii::app()->user->hasFlash('errorTopic') ? unserialize(Yii::app()->user->getFlash('errorTopic')) : null ?>
          <!-- START OF MAINCOL -->
          <div class="MainCol AddEbookPage">
          	  <h1>添加心理测试主题</h1>
              <span class="NormalFont SmallFont">
                  <?= CHtml::image(Yii::app()->baseUrl.'/images/home_icon.gif', '主页'); ?> > 心理测试管理 > 添加心理测试主题
               </span><br /><br />
              <div class="Titlebox box"><!-- DON'T DELETE --></div>

              <?php if($topic->hasErrors()):  echo CHtml::errorSummary($topic); elseif(isPost()): ?>
              <div class="SuccessfulBox Smallbox">
                <span class="Successful"> 心理测试主题成功保存。</span>
              </div>
              <?php endif; ?>

              <?php if(Yii::app()->user->hasFlash('successMessage')) : ?>
              <div class="SuccessfulBox Smallbox">
                <span class="Successful"> <?php echo Yii::app()->user->getFlash('successMessage'); ?></span>
              </div>
              <?php endif; ?>
				<?php if($errorTopic !== null) : $topic = $errorTopic ?>
	            <?php echo CHtml::errorSummary($errorTopic) ?>
	            <?php endif ?>
			
              <?= CHtml::form(array('/admin/psytest/addtopic'), 'POST', array('name' => 'form1', 'enctype' => 'multipart/form-data')); ?>
              <div class="Smallbox"><label>标题<span class="Red">*</span></label>
                  <?= CHtml::activeTextField($topic, 'topicTitle', array('class' => 'TxtInput')); ?>
              </div>
              
              <div class="Smallbox"><label>分类</label>
                  <?= CHtml::activeDropDownList($topic, 'psyTestCategoryId', CHtml::listData($categories, 'psyTestCategoryId', 'categoryName'), array('empty' => '-请选择分类-')); ?>
              </div>

              <div class="Smallbox"><label>主题图片<span class="Red">*</span></label>
              	<input type="file" id="TestTopics_topicImage" name="TestTopics[topicImage]" class="TxtInput" />
              </div>
              
              <div class="Smallbox"><label>类型<span class="Red">*</span></label>
                  <?= CHtml::activeDropDownList($topic, 'topicType', TestTopics::topicType2Text()); ?>
              </div>
              
              <div class="Smallbox"><label>使用二次维度</label>
              	 <?php echo CHtml::activeDropDownList($topic, 'hasSecDim', TestTopics::hasSecDimOptions()) ?>
              </div>
              
              <div class="Smallbox"><label>元关键字</label>
                  <?= CHtml::activeTextArea($topic, 'metaKey', array('class' => 'TxtInput')); ?>（请以半角逗号“,”分割关键字）
              </div>

              <div class="Smallbox"><label>元描述</label>
                  <?= CHtml::activeTextArea($topic, 'metaDescr'); ?>
              </div>

              <div class="Smallbox"><label>主题描述<span class="Red">*</span></label>
                  <?= CHtml::activeTextArea($topic, 'topicDescr', array('style' => 'height: 120px;')); ?>
              </div>

              <div class="Midbox Red SmallFont Smallbox"><label>&nbsp;</label>带 * 为必填项</div>

              <div class="Smallbox btnBox"><label>&nbsp;</label>
              	  <?= CHtml::submitButton('保存', array('title' => '保存', 'name' => 'submitPost')); ?>
                  或 <?= CHtml::link('返回', array('admin/psytest')); ?>
                  <br class="clear" />
              </div>
              <?= CHtml::endForm(); ?>

          </div>
          <!-- END OF MAINCOL -->
<script type="text/javascript">
$(document).ready(function() {
	$('#TestTopics_topicType').change(function() {
		if($(this).val() == <?php echo TestTopics::TYPE_MARK_SINGLE_CONLUSION ?> || $(this).val() == <?php echo TestTopics::TYPE_MARK_MULTI_CONLUSIONS ?>) {
			$('#TestTopics_hasSecDim').parent('div').show();
		} else {
			$('#TestTopics_hasSecDim').parent('div').hide();
		}
	});
});
</script>